package com.aqie.medium.game;

/**
 * todo 为什么求直线距离不行
 * [[1,8],[-9,0],[-7,-6],[4,3],[1,3]]
 * [6,-9]
 * 输出 false
 * 789 吃人豆
 */
public class EscapeGhosts {
    public boolean escapeGhosts(int[][] ghosts, int[] target) {
        double length = Math.abs(target[0]) + Math.abs(target[1]);
        // 计算两点距离
        for (int[] ghost : ghosts) {
            double s = Math.abs(ghost[0] - target[0]) + Math.abs(ghost[1] - target[1]);
            if (s <= length) return false;
        }
        return true;
    }

    public static void main(String[] args) {
        int[][] ghosts = {{1,8},{-9,0},{-7,-6},{4,3},{1,3}};
        for (int i = 0; i < ghosts.length; i++){
            double s = Math.pow(ghosts[i][0], 2) + Math.pow(ghosts[i][1],2);
            System.out.println(s);
        }
    }
}
